const successCallback = () => {console.warn("showModule未指定点击确定的回调！")}
const errorCallback = () => {console.warn("showModule未指定点击取消的回调！")}

/**
 * @description 成功消息提示
 * @author zhaojiuyi
 * @param {string} 提示内容  
 * @date 2022
 * */
export const successMsg = (title) => {
	uni.showToast({
		title,
		icon: 'success',
		duration: 2000
	})
}


/**
 * @description 错误消息提示
 * @author zhaojiuyi
 * @param {string} 提示内容  
 * @date 2022
 * */
export const errorMsg = (title) => {
	uni.showToast({
		title,
		icon: 'error',
		duration: 2000
	})
}

/**
 * @description 消息提示
 * @author zhaojiuyi
 * @param {string} 提示内容  
 * @param {Function} 点击确定后的回调函数  
 * @date 2022
 * */
export const showTitleModule = (title,sucFunc=successCallback) => {
	uni.showModal({
		title: '提示',
		content: title,
		showCancel: false,
		success: function(){
			sucFunc()
		}
	})
}

/**
 * @description 有取消按钮的提示框
 * @author zhaojiuyi
 * @param {string}  提示文字
 * @param {Function}  点击确定的回调函数
 * @param {Function}  点击取消的回调函数
 * @date 2022
 * */
export const showCancelModule = (title,sucFunc=successCallback,cancelFunc=errorCallback) => {
	uni.showModal({
		title: '提示',
		content: title,
		showCancel: true,
		success: function({confirm,cancel}){
			if(confirm) {sucFunc()}
			if(cancel) {cancelFunc()}
		}
	})
}

/**
 * @description 有输入框的提示框
 * @author zhaojiuyi
 * @param {string}  提示文字
 * @return {Promise} 输入的文本框内容
 * @date 2022
 * */
export const showInputModule = title => new Promise((resolve,reject) => {
	uni.showModal({
		title,
		editable: true,
		showCancel: true,
		success: function({content,confirm,cancel}){
			if(confirm) {resolve(content)}
			if(cancel) {reject()}
		},
		fail(){
			reject()
		}
	})
})
